package com.erp.module.dingDan

import android.content.Context
import com.erp.bean.OrderSousuoBean
import com.erp.bean.ProductionBean
import com.erp.Interface.OnUserDataInterface
import com.erp.pull.BasePullP
import org.json.JSONArray
import org.json.JSONObject

/**
 * Created by Administrator on 2019/3/18/018.
 */
class IDingDanP(var list : MutableList<ProductionBean>, var context : Context, var V : DingDanContract.DingDanView) :BasePullP(),DingDanContract.DingDanP {

    var  md : DingDanContract.DingDanMP = DingDanModel()
    var sousuoBean: OrderSousuoBean = OrderSousuoBean()
    init {
        PullV=V
    }
    override fun getData(page: Int, pagesize: Int, onUserDataInterface: OnUserDataInterface) {
        md.getHttpOrder(context,page,pagesize,sousuoBean,onUserDataInterface)
    }

    override fun jsondata(data: String?) {
        if (data==null){
            return
        }
        try {
            val js = JSONArray(data)
            for (i in 0 until js.length()) {
                val jo = js.get(i) as JSONObject
                val productionban = ProductionBean()
                productionban.id = jo.getString("id")
                productionban.onum = jo.getString("onum")
                productionban.contract_num = jo.getString("contract_num")
                productionban.customer = jo.getString("customer")
                productionban.tel = jo.getString("tel")
                productionban.ot_name = jo.getString("ot_name")
                productionban.content_description = jo.getString("content_description")
                productionban.shop_name = jo.getString("shop_name")
                productionban.special_status = jo.getString("special_status")
                productionban.special_service_cat = jo.getString("special_service_cat")
                list.add(productionban)
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    override fun listClean() {
        list.clear()
    }
    override fun sousuo(sousuoBean: OrderSousuoBean) {
        this.sousuoBean=sousuoBean
    }

}